
#include "stdafx.h"
#include "externaldispatch.h"

STDMETHODIMP_(ULONG) CExternalDispatch::AddRef()
{
	return ++m_cRef;
}

STDMETHODIMP_(ULONG) CExternalDispatch::Release()
{
	long nTemp = --m_cRef;

	if (nTemp == 0)
		delete this;

	return nTemp;
}

STDMETHODIMP CExternalDispatch::QueryInterface(const IID &riid, void **ppvObject)
{
	if (ppvObject == NULL)
		return E_INVALIDARG;

	*ppvObject = NULL;

	if (riid == IID_IUnknown || riid == IID_IDispatch) 
		*ppvObject = (IDispatch*)(this); 

	if (*ppvObject)
	{
		((LPUNKNOWN)*ppvObject)->AddRef();
		return S_OK;
	}

	return E_NOINTERFACE ;
}

// IDispatch
STDMETHODIMP CExternalDispatch::GetTypeInfoCount(UINT *pctinfo)
{
	return E_NOTIMPL ;
}

STDMETHODIMP CExternalDispatch::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
	return E_NOTIMPL ;
}

STDMETHODIMP CExternalDispatch::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
	return E_NOTIMPL;
}

STDMETHODIMP CExternalDispatch::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
	return E_NOTIMPL ; 
}